package jgl.vajra.kingkong.part.vehicle.viewModel;

import java.util.Map;

import jgl.vajra.kingkong.bean.OrderDetailsBean;
import jgl.vajra.kingkong.bean.OrderPaymentDetailsBean;
import jgl.vajra.kingkong.part.vehicle.contract.OrderStatusContract;
import jgl.vajra.kingkong.part.vehicle.model.OrderStatusModel;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateModel;
import jgl.vajra.kingkong.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(OrderStatusModel.class)
public class OrderStatusViewModel extends OrderStatusContract.ViewModel{
    @Override
    public void getOrderPaymentDetailsData(Map<String, Object> map) {
        mModel.getOrderPaymentDetailsData(map).subscribe(new ProgressObserver<OrderPaymentDetailsBean>(false,this) {
            @Override
            public void _onNext(OrderPaymentDetailsBean data) {
                mView.returnOrderPaymentDetailsData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void cancelOrder(Map<String, Object> map) {
        mModel.cancelOrder(map).subscribe(new ProgressObserver<String>(true, this) {
            @Override
            public void _onNext(String s) {
                mView.returnCancelOrder();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getOrderDetailsData(Map<String, Object> map) {
        mModel.getOrderDetailsData(map).subscribe(new ProgressObserver<OrderDetailsBean>(false,this) {
            @Override
            public void _onNext(OrderDetailsBean data) {
                mView.returnOrderDetailsData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void determineOrderCompleteData(Map<String, Object> map) {
        mModel.determineOrderCompleteData(map).subscribe(new ProgressObserver<Object>(true,this) {
            @Override
            public void _onNext(Object o) {
                mView.returnDetermineOrderCompleteData();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }
}
